#include <stdio.h>
#include <errno.h>


FILE * Log_us;
FILE * Log_deb;
#define LOG_MAX 100;


void init_logger(){
	Log_us = fopen("log-user.dat", "w+");
	Log_deb = fopen("log-debug.dat", "w+");
	fclose(Log_us);
	fclose(Log_deb);
	};
  
void do_info(const char * time, const char * func, int line){
		Log_us = fopen("log-user.dat", "w+");
		Log_deb = fopen("log-debug.dat", "W+");		  
		fprintf(Log_us,"Info: %s %d %s - done.\n", time, line, func);
		fprintf(Log_deb,"Info: %s %d %s - done.\n", time, line, func);
		fclose(Log_us);
		fclose(Log_deb);	 	
			}


void do_erorr( const char * time,  const char * func, int line){	
			Log_us = fopen("log-user.dat", "w+");
			Log_deb = fopen("log-debug.dat", "w+");
			fprintf(Log_us,"ERORR: %s %d %s\n", time, line, func);
			fprintf(Log_deb,"ERORR: %s %d %s errno = %s\n", time, line, func, (char *)strerror(errno));	
			fclose(Log_us);
			fclose(Log_deb);
			}

void LOG(const char * time,const char* func, int line, int result){
		if (result == 1) do_info(time, func, line);
		else do_erorr( time, func, line);
	}	
#define log(one) LOG(__TIME__,__func__,__LINE__, one)		

